<div class="h_top"><h2>确认信息</h2><a class="close_box">×</a></div>
<div class="fl shu_box">
    <select name="reason" class="reason">
        <option value="0">请选择关闭原因</option>
        <option value="1">买家不买</option>
        <option value="2">订单信息填错，需要重拍</option>
        <option value="3">缺货</option>
        <option value="4">同城见面交易</option>
        <option value="5">拍错了</option>
        <option value="99">其它原因</option>
    </select>
    <p>您确定要取消该订单吗？取消订单后，不能恢复。</p>
    <div class="jm_error"></div>
</div>
<div class="btn_box">
    <div class="btn_cancel fr close_box">取消</div>
    <div class="btn_confirm fr btn_reason" data-id="{{$order_id}}" data-url="">确定</div>
</div>

<script>
    var order_update = '/member/seller/orders/{id}';
    $('.close_box').click(function(){
        $('.bg_h').hide();
        $('.delivery_bombbox').hide();
        $('.trade_close_bombbox').hide();
    });

    $('.btn_reason').click(function(){
        var order_id = $(this).data('id');
        var url = order_update.replace('{id}', order_id);
        var cancel_reason = $('.reason option:selected').val();
        if(cancel_reason == 0){
            layer.alert('请选择关闭原因', {
                icon: 2
            });
        }else{

            if(confirm("你确定关闭吗？")){
                $.ajax({
                    url: url,
                    type: 'PUT',
                    dataType: 'json',
                    data: {order_status: 5, cancel_reason: cancel_reason},
                    success:function(data){
                        if(0==data.code){
                            layer.alert("关闭成功", {
                                icon: 1
                            }, function () {
                                location.reload();
                            });
                        }else{
                            layer.alert(data.message, {
                                icon: 2
                            });
                        }
                    }
                });
            }

        }
    });
</script>